package com.web.dao;

import com.web.entity.Address;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * @author FDjavaone
 */
public class AddressSqlProvider {


    public String insertSelective(Address record) {
        BEGIN();
        INSERT_INTO("t_address");

        if (record.getmId() != null) {
            VALUES("m_id", "#{mId,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }

        if (record.getPhone() != null) {
            VALUES("phone", "#{phone,jdbcType=VARCHAR}");
        }

        if (record.getProvince() != null) {
            VALUES("province", "#{province,jdbcType=VARCHAR}");
        }

        if (record.getCity() != null) {
            VALUES("city", "#{city,jdbcType=VARCHAR}");
        }

        if (record.getRegion() != null) {
            VALUES("region", "#{region,jdbcType=VARCHAR}");
        }

        if (record.getStreet() != null) {
            VALUES("street", "#{street,jdbcType=VARCHAR}");
        }

        if (record.getAddress() != null) {
            VALUES("address", "#{address,jdbcType=VARCHAR}");
        }

        if (record.getDefaultStatus() != null) {
            VALUES("default_status", "#{defaultStatus,jdbcType=INTEGER}");
        }

        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }

        return SQL();
    }


    public String updateByPrimaryKeySelective(Address record) {
        BEGIN();
        UPDATE("t_address");

        if (record.getmId() != null) {
            SET("m_id = #{mId,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }

        if (record.getPhone() != null) {
            SET("phone = #{phone,jdbcType=VARCHAR}");
        }

        if (record.getProvince() != null) {
            SET("province = #{province,jdbcType=VARCHAR}");
        }

        if (record.getCity() != null) {
            SET("city = #{city,jdbcType=VARCHAR}");
        }

        if (record.getRegion() != null) {
            SET("region = #{region,jdbcType=VARCHAR}");
        }

        if (record.getStreet() != null) {
            SET("street = #{street,jdbcType=VARCHAR}");
        }

        if (record.getAddress() != null) {
            SET("address = #{address,jdbcType=VARCHAR}");
        }

        if (record.getDefaultStatus() != null) {
            SET("default_status = #{defaultStatus,jdbcType=INTEGER}");
        }

        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }

        WHERE("id = #{id,jdbcType=BIGINT}");

        return SQL();
    }




}